import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		$userInfo: {},
		$token: '',
		$order:[],
		$comment : 0,
		$goods_like : 0,
	},
	mutations: {
		login(state, data) {
			state.$token = data.token;
			state.$userInfo = data.userInfo;
			uni.setStorageSync('token', data.token);
			uni.setStorageSync('userInfo', data.userInfo);
		},
		logout(state) {
			state.$token = '';
			state.$userInfo = {};
			uni.removeStorageSync('token');
			uni.removeStorageSync('userInfo');
		},
		stat(state, data){
			state.$order = data.order;
			state.$comment = data.comment;
			state.$goods_like = data.goods_like;
		}
	}
})

export default store
